<%@ page language="java" import="java.util.*,com.hs.auth.model.*,com.hs.dnms.model.*" pageEncoding="utf-8"%>
 <% 
  DnmsDisease disobj = (DnmsDisease)request.getAttribute("disobj"); 
  List pointlist  = new ArrayList();
  %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ include file="../../include.jsp"%>  
<script language="javascript" type="text/javascript" src="<%=basePath%>common/uploadify/jquery-1.4.2.min.js"></script>
<script language="javascript" type="text/javascript" src="<%=basePath%>common/javascripts/My97DatePicker/WdatePicker.js"></script>
<script language="javascript" type="text/javascript" src="<%=basePath%>common/uploadify/jquery.uploadify.v2.1.4.js"></script>
<script type="text/javascript" src="<%=basePath%>common/uploadify/swfobject.js"></script>
<LINK rel=stylesheet type=text/css href="<%=basePath%>common/uploadify/uploadify.css"/>  
<script src='<%=basePath%>dwr/interface/dataProhelper.js'></script>  

<script language="javascript" type="text/javascript">
function dataPro(id){
	window.location.href="";

}
  
/**穴位组信息保存*/
function saveParainfo(id){
 	var paraname = document.getElementById("paraname").value; 
 	if("" == id){
 		alert("请先选择该穴位组对应的疾病!");
 		return ;
 	}
	if(isNull(paraname)){
		alert("请输入穴位组名称！");
		return; 
    }
    dataProhelper.addPointGroup(paraname,'',id,callback4addPara);
}
function callback4addPara(data){ 
	   var index = data.indexOf("$");
       var paraid = data.substring(0,index);
       var paraname = data.substring(index+1);  
       var str = "<span id=para_"+paraid+"><input type=radio onclick=viewpoint('"+paraid+"') value="+paraid+" name=pgroup id=pgroup/><font size='5'>" + paraname+"</font>&nbsp;&nbsp;<a href='javaScript:delPara("+paraid+");'>删除</a>&nbsp;&nbsp;</span>";
       var objHtml = document.getElementById("paras");
       var temp = objHtml.innerHTML + str;
       objHtml.innerHTML = temp; 
       document.getElementById("paraname").value='';
       document.getElementById("paraname").focus();
       alert('穴位组信息保存成功！');   
       
}
function delPara(id){
	if(confirm("确认要删除该穴位组吗？")){
			dataProhelper.queryPointcout(id,callback4delcheck);
	
    }
}
function callback4delcheck(data){
	if("" == data){
		alert("请先删除该穴位组相关的穴位");
		return; 
	}else{
		dataProhelper.delPointGroup(data,callback4delPara);
		
	}
}
function callback4delPara(data){   
	document.getElementById("para_"+data).style.display="none"; 
}

/**穴位信息保存*/
function savePointinfo(id){
    var groupid = getRadioValue("pgroup"); 
 	if("undefined" == typeof(groupid)){
		alert("请先选择该穴位相关的穴位组！");
		return;
	}  
 	var paraname = document.getElementById("pointname").value;  
	if(isNull(paraname)){
		alert("请输入穴位名称！");
		return; 
    }
    dataProhelper.addPoint(paraname,'',groupid,callback4addPoint);
}
function callback4addPoint(data){ 
	   var index = data.indexOf("$");
       var paraid = data.substring(0,index);
       var paraname = data.substring(index+1);  
       var str = "<span id=point_"+paraid+"><font size='5'>" + paraname+"</font>&nbsp;&nbsp;<a href='javaScript:delPoint("+paraid+");'>删除</a>&nbsp;&nbsp;</span>";
       var objHtml = document.getElementById("points");
       var temp = objHtml.innerHTML + str;
       objHtml.innerHTML = temp; 
       document.getElementById("pointname").value='';
       document.getElementById("pointname").focus();
       alert('穴位信息保存成功！');   
}
function delPoint(id){
	if(confirm("确认要删除该穴位吗？")){
    		dataProhelper.delPoint(id,callback4delPoint);
    }
}
function callback4delPoint(data){    
	document.getElementById("point_"+data).style.display="none"; 
}
function viewpoint(id){
	dataProhelper.queryPointByGroupid(id,callback4viewpoint); 
}
function callback4viewpoint(data){
	 var objHtml = document.getElementById("points");
	 objHtml.innerHTML = data;
 }
</script>
</head>
<body>
 
<div class="deta_proce" style="border-top:none;margin-left:0"> 
    <div>
        <table border="0" cellspacing="0" cellpadding="0"  class="atta_tab">
          <caption>穴位组信息</caption> 
          <tr>
	            <td id="paras">
           <%
            if(null != disobj && !(disobj.getPointset().isEmpty())){  
                    Iterator paraiter = disobj.getPointset().iterator(); 
                   while(paraiter.hasNext()){ 
          	             DnmsPointgroup para = (DnmsPointgroup)paraiter.next(); 
          	             Long pid = para.getId(); 
          	             out.print("<span id=para_"+pid+"><input type=radio onclick='viewpoint("+pid+")' value="+pid+" name=pgroup id=pgroup/><font size='5'>"+para.getPgroupname()+"</font>");
          	             out.print("<a href=javaScript:delPara('"+pid+"');>");
          	             out.print("删除</a></span>"); 
          	             Set pset = para.getPointset();
          	             if(!pset.isEmpty()){
          	             	 pointlist.addAll(pset);
          	             }
           }}else{ 
               } %> 
           </td> 
	          </tr> 
        </table>
         <table border="0" cellspacing="0" cellpadding="0"> 
          <tr>
            <td width="20%">穴位组：</td> 
            <td><input type="text" name="paraname" id="paraname" style="width:99%"/></td>
            <td width="15%"><input onclick="saveParainfo('<%=disobj==null?"1":disobj.getId() %>')" type="button" value=" 保 存 " class="butt4"/></td>
          </tr>  
           
        </table>  
        <table border="0" cellspacing="0" cellpadding="0"  class="atta_tab">
          <caption>穴位信息</caption> 
          <tr>
	            <td id="points">
           <%
            if(pointlist.size()>0){  
               for(int i=0;i<pointlist.size();i++){
          	      DnmsPoint para = (DnmsPoint)pointlist.get(i);
          	      Long pid = para.getId(); 
          	      out.print("<span id=point_"+pid+"><font size='5'>"+para.getPointname()+"</font>");
          	      out.print("<a href=javaScript:delPoint('"+pid+"');>");
          	      out.print(" 删 除 </a></span>"); 
           }}else{ 
               } %> 
           </td> 
	          </tr> 
        </table>
         <table border="0" cellspacing="0" cellpadding="0"> 
          <tr>
            <td width="20%">穴位：</td> 
            <td><input type="text" name="pointname" id="pointname" style="width:99%"/></td>
            <td width="15%"><input onclick="savePointinfo()" type="button" value=" 保 存 " class="butt4"/></td>
          </tr>  
           
        </table>  
    </div>
</div>
</body>
</html>

